//
//  MOLaderEvaluationListCell.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/8/12.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#define CELLWIDTH SCREEN_WIDTH - 30

#import "MOLaderEvaluationListCell.h"

@interface MOLaderEvaluationListCell ()

@property(nonatomic,strong)UIImageView *iconImageView;

@property(nonatomic,strong)UILabel *nameLabel;

@property(nonatomic,strong)UILabel *gradeLabel;

@property(nonatomic,strong)UIView *lineView;

@property(nonatomic,strong)UILabel *companylabel;

@property(nonatomic,strong)UILabel *sectionLabel;

@property(nonatomic,strong)UILabel *dutyLabel;

@property(nonatomic,strong)UILabel *categoryLabel;

@end

@implementation MOLaderEvaluationListCell

+(instancetype)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    //NSString *ID = [NSString stringWithFormat:@"Cell%ld%ld",(long)[indexPath section],(long)[indexPath row]];
    NSString *ID = @"MOLaderEvaluationListCell";
    MOLaderEvaluationListCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil){
        cell = [[MOLaderEvaluationListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell creatView];
    }
    return cell;
}


-(void)creatView
{
    self.backgroundColor = KWhiteColor;
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 15.0;
    
    [self addSubview:self.iconImageView];
    
    [self addSubview:self.nameLabel];
    
    [self addSubview:self.gradeLabel];
    
    [self addSubview:self.lineView];
    
    [self addSubview:self.companylabel];
    
    [self  addSubview:self.sectionLabel];
    
    [self addSubview:self.dutyLabel];
    
    [self addSubview:self.categoryLabel];
}

-(void)setModel:(MOLaderEvaluationListModel *)model
{
//    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.nameIconStr] placeholderImage:IMAGE(@"")];
    
    self.nameLabel.text = model.nameStr;
    
    if ([model.gradeStr isEqualToString:@"好"]) {
        self.gradeLabel.textColor = KGreenColor_8CD72C;
    }else if ([model.gradeStr isEqualToString:@"较好"]){
        self.gradeLabel.textColor = KBlueColor_2C94FF;
    }else if ([model.gradeStr isEqualToString:@"一般"]){
        self.gradeLabel.textColor = KRedColor_FD744F;
    }else{
        self.gradeLabel.textColor = KRedColor_FD744F;
    }
    self.gradeLabel.text = model.gradeStr;
    
    self.companylabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"所属单位\t%@",model.companyStr] subString:model.companyStr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
    
    self.sectionLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"所属部门\t%@",model.sectionStr] subString:model.sectionStr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
    
    self.dutyLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"职务\t\t%@",model.dutyStr] subString:model.dutyStr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
    
    self.categoryLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"人员类别\t%@",model.peopleCategoryStr] subString:model.peopleCategoryStr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
}


#pragma mark --
-(UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 0.001, 30)];
        _iconImageView.layer.masksToBounds = YES;
        _iconImageView.layer.cornerRadius = 15;
        _iconImageView.backgroundColor = KGrayColor_ededed;
    }
    return _iconImageView;
}

-(UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(_iconImageView.right + 8, 0, 150, 17)];
        _nameLabel.font = [UIFont boldSystemFontOfSize:16];
        _nameLabel.textColor = KBlackColor_2A2A2A;
        _nameLabel.centerY = _iconImageView.centerY;
    }
    return _nameLabel;
}

-(UILabel *)gradeLabel
{
    if (!_gradeLabel) {
        _gradeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CELLWIDTH - 24 - 40, 0, 40, 16)];
        _gradeLabel.font = FONT_SIZE(15);
        _gradeLabel.textAlignment = NSTextAlignmentRight;
        _gradeLabel.centerY = _iconImageView.centerY;
    }
    return _gradeLabel;
}

-(UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, _iconImageView.bottom + 9, CELLWIDTH, 1)];
        _lineView.backgroundColor = KGrayColor_ededed;
    }
    return _lineView;
}

-(UILabel *)companylabel
{
    if (!_companylabel) {
        _companylabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _lineView.bottom + 17, CELLWIDTH - 34, 15)];
        _companylabel.textColor = KGrayColor_919395;
        _companylabel.font = FONT_SIZE(14);
    }
    return _companylabel;
}

-(UILabel *)sectionLabel
{
    if (!_sectionLabel) {
        _sectionLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _companylabel.bottom + 17, CELLWIDTH - 34, 15)];
        _sectionLabel.textColor = KGrayColor_919395;
        _sectionLabel.font = FONT_SIZE(14);
    }
    return _sectionLabel;
}

-(UILabel *)dutyLabel
{
    if (!_dutyLabel) {
        _dutyLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _sectionLabel.bottom + 17, CELLWIDTH - 34, 15)];
        _dutyLabel.textColor = KGrayColor_919395;
        _dutyLabel.font = FONT_SIZE(14);
    }
    return _dutyLabel;
}

-(UILabel *)categoryLabel
{
    if (!_categoryLabel) {
        _categoryLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _dutyLabel.bottom + 17, CELLWIDTH - 34, 15)];
        _categoryLabel.textColor = KGrayColor_919395;
        _categoryLabel.font = FONT_SIZE(14);
    }
    return _categoryLabel;
}




@end
